package com.yuhanxun.util;

import android.content.Context;
import android.content.SharedPreferences;

public class DealPreferences {
	public static long readLongPreferences(String perferencesName, String key, Context con) {
		SharedPreferences preferences = con.getSharedPreferences(perferencesName, Context.MODE_PRIVATE);
		long result = preferences.getLong(key, 0);
		return result;
	}

	public static  int readIntPreferences(String perferencesName, String key, Context con) {
		SharedPreferences preferences = con.getSharedPreferences(perferencesName, Context.MODE_PRIVATE);
		int result = preferences.getInt(key, 0);
		return result;
	}
	
	public static  void writeLongPreferences(String perferencesName, String key, long value, Context con) {
		SharedPreferences preferences = con.getSharedPreferences(perferencesName, 0);
		SharedPreferences.Editor editor = preferences.edit();
		editor.putLong(key, value).commit();
	}

	public static  void writeIntPreferences(String perferencesName, String key, int value, Context con) {
		SharedPreferences preferences = con.getSharedPreferences(perferencesName, 0);
		SharedPreferences.Editor editor = preferences.edit();
		editor.putInt(key, value).commit();
	}

	public static  void writeBooleanPreferences(String perferencesName, String key, Boolean value, Context con) {
		SharedPreferences preferences = con.getSharedPreferences(perferencesName, 0);
		SharedPreferences.Editor editor = preferences.edit();
		editor.putBoolean(key, value).commit();
	}
}
